<template name="databaseStats">
    {{> pageHeading title='Nosqlclient' }}
    {{#if Template.subscriptionsReady}}
        {{#if isConnected}}
            {{#if getServerStatus}}
                <div class="row m-b-lg m-t-lg">
                    <div class="col-md-9">

                        <div class="profile-info">
                            <div class="">
                                <div>
                                    <h2 class="no-margins">
                                        {{getServerStatus.host}}
                                    </h2>
                                    <h4>{{{_ "server_uptime" uptime=getServerStatus.uptime}}}</h4>
                                    <small>
                                        {{{_ "db_stats_info"}}}
                                        {{{_ "mongodb_version_info" version=getServerStatus.version}}}<br/>
                                        {{{_ "process_id_info" pid=getServerStatus.pid}}}<br/>
                                        {{{_ "process_name_info" name=getServerStatus.process}}}<br/>
                                    </small>
                                </div>
                            </div>
                        </div>
                    </div>

                    {{#if getDBStats}}
                        <div class="col-md-3">
                            <table class="table small m-b-xs">
                                <tbody>
                                <tr>
                                    <td>
                                        {{{_ "collections_info" count=getDBStats.collections}}}
                                    </td>
                                    <td>
                                        {{{_ "objects_info" count=getDBStats.objects}}}
                                    </td>

                                </tr>
                                <tr>
                                    <td>
                                        {{{_ "data_size_info" count=getDBStats.dataSize}}}
                                    </td>
                                    <td>
                                        {{{_ "storage_size_info" count=getDBStats.storageSize}}}
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        {{{_ "indexes_info" count=getDBStats.indexes}}}
                                    </td>
                                    <td>
                                        {{{_ "index_size_info" count=getDBStats.indexSize}}}
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        {{{_ "file_size_info" count=getDBStats.fileSize}}}
                                    </td>
                                    <td>
                                        {{{_ "extents_info" count=getDBStats.numExtents}}}
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    {{/if}}
                </div>

                <!-- CHARTS -->
                <div class="wrapper wrapper-content animated fadeInRight">
                    <!-- MEMORY USAGE -->
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "memory_usage"}}</h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="divHeapMemoryChart" class="flot-chart">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <!-- QUEUED READ/WRITE -->
                        <div class="col-lg-6">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "queued_write_read"}} <span id="spanTotalQueuedRW"></span></h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="divQueuedReadWrite" class="flot-chart">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- ACTIVE READ/WRITE -->
                        <div class="col-lg-6">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "active_write_read"}} <span id="spanTotalActiveRW"></span></h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="divActiveReadWrite" class="flot-chart">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <!-- CONNECTIONS -->
                        <div class="col-lg-6">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "connections"}} <span id="spanAvailableConnections"></span></h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="divConnectionsChart" class="flot-chart">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- NETWORK -->
                        <div class="col-lg-6">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "network"}} <span id="spanTotalRequests"></span></h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="divNetworkChart" class="flot-chart">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- COLLECTION READ/WRITE -->
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "collections_read_write"}}</h5>
                                </div>
                                <div id="divCollectionsReadWrite" class="ibox-content">
                                    <table id="tblCollectionsReadWrite"
                                           class="table table-striped table-bordered table-hover dataTables-example dataTable"
                                           style="width: 100%">
                                        <thead>
                                        <tr>
                                            <th>{{_ "collection"}}</th>
                                            <th>{{_ "read"}} ({{_ "microseconds"}})</th>
                                            <th>{{_ "write"}} ({{_ "microseconds"}})</th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- OP COUNTERS -->
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <h5>{{_ "op_counters"}}</h5>
                                </div>
                                <div class="ibox-content">
                                    <div id="divOperationCountersChart" class="flot-chart">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            {{else}}
                <div class="wrapper wrapper-content animated fadeInRight">
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="text-center m-t-lg">
                                <h1>{{_ "stats_disabled"}}</h1>
                                <small id="errorMessage">
                                    {{{_ "stats_info"}}}
                                </small>
                            </div>
                        </div>
                    </div>
                </div>
            {{/if}}
        {{else}}
            <div class="wrapper wrapper-content animated fadeInRight">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="text-center m-t-lg">
                            <h1>
                                <img width="300" height="200" src="logo/new/image_with_text2.png"/>
                            </h1>
                        </div>
                    </div>
                </div>
                <!--<div class="row">
                <div class="col-lg-6 col-lg-offset-3">
                    <div class="text-center m-t-lg">
                        <div class="panel panel-primary">
                            <div class="panel-heading">
                                {{{_ "help_us"}}}
                            </div>
                            <div class="panel-body">
                                <p>{{{_ "donation_info"}}}</p>
                                <p>
                                    <b>BTC: </b><i>34RHhcvbS5kYFEgRXQURnpcGkn3LvMQB4k </i><br/><br/>
                                    <b>ETH / ERC-20: </b><i>0xA5B7922F058b4675DcE7ACfDC6d43E9b8eC68De6</i><br/><br/>
                                    <b>NEO: </b><i>AQvAHSXchhdLJP6BJdc1LRzhrPsaMhPzr6</i><br/><br/>
                                    <b>Paypal: </b><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y5VD95E96NU6S">Donate</a>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>-->
                <div class="row">
                    <div class="col-lg-12">
                        <div class="text-center m-t-lg">
                            <small>
                                {{{_ "use_our_github"}}}<br/>
                                {{{_ "github_link"}}}
                            </small>
                        </div>
                    </div>
                </div>
            </div>
        {{/if}}
    {{/if}}

</template>
